package com.example.demo;

import com.example.api.JobExecutor;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.firenio.codec.http11.HttpCodec;
import com.firenio.component.ChannelAcceptor;
import com.firenio.component.IoEventHandle;
import com.firenio.component.LoggerChannelOpenListener;

/**
 * @author fanhang
 */
public class FirenioBoot {

    public static void main(String[] args) throws Exception {
        JsonMapper jsonMapper = JsonMapper.builder().build();
        JobExecutor jobExecutor = new JobExecutor();
        IoEventHandle handle = new FirenioHandler(jsonMapper, jobExecutor);
        ChannelAcceptor channelAcceptor = new ChannelAcceptor(9090);
        channelAcceptor.addChannelEventListener(new LoggerChannelOpenListener());
        channelAcceptor.setIoEventHandle(handle);
        channelAcceptor.addProtocolCodec(new HttpCodec());
        channelAcceptor.bind();
    }

}
